# Configure template for GNU shar utilities.
# Copyright (C) 1994 Free Software Foundation, Inc.
# Process this file with autoconf to produce a configure script.

# FIXME: AC_HAVE_HEADERS(sys/time.h)
# FIXME: AC_HAVE_FUNCS(gethostname getwd)

AC_INIT(src/shar.c)
AC_CONFIG_HEADER(config.h)
AC_ARG_PROGRAM

PACKAGE=sharutils
VERSION=4.2
ALL_LINGUAS="de fr ja_JP.EUC nl pt sv"
PROGRAMS="shar unshar"
SCRIPTS="mail-files mailshar"
MAN1PAGES="shar unshar"
MAN5PAGES=
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
AC_SUBST(PROGRAMS)
AC_SUBST(SCRIPTS)
AC_SUBST(MAN1PAGES)
AC_SUBST(MAN5PAGES)

changequote(,)dnl
case $VERSION in
  [0-9]*.[0-9]*.[0-9]*) DIST_ALPHA="README-alpha";;
  *) DIST_ALPHA=;;
esac
changequote([, ])dnl
AC_SUBST(DIST_ALPHA)

AC_PROG_CC
fp_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_RANLIB

dnl FIXME: Check that it is GNU diff indeed.
# Carefully avoid gdiff for X as found on SGI systems.
if (DISPLAY= gdiff /dev/null /dev/null) 2> /dev/null; then
  AC_PATH_PROGS(DIFF, gnudiff diffgnu gdiff diff, no)
else
  AC_PATH_PROGS(DIFF, gnudiff diffgnu diff, no)
fi

dnl FIXME: Check that mailer accepts -s.
PATH_save="$PATH"; PATH="$PATH:/usr/sbin:/usr/ucb:/usr/bin:/bin"
AC_PATH_PROGS(MAILER, Mail mailx elm mush mail, no)
PATH="$PATH_save"

dnl FIXME: Check that perl was found.
AC_PATH_PROG(PERL, perl, no)

AC_PATH_PROGS(SH, bash sh, no)

dnl FIXME: Check that it is GNU tar indeed.
AC_PATH_PROGS(TAR, gnutar targnu gtar tar, tar)

test $ac_cv_path_PERL = no || SCRIPTS="$SCRIPTS remsync"

AC_AIX
AC_ISC_POSIX
AC_MINIX
AC_C_CROSS
if test $cross_compiling = no; then
  AC_C_CHAR_UNSIGNED
fi
fp_C_PROTOTYPES
AC_C_CONST
AC_C_INLINE
AC_C_BIGENDIAN

AC_CHECK_HEADERS(limits.h locale.h memory.h string.h sys/wait.h unistd.h)
AC_HEADER_DIRENT
AC_HEADER_STAT
AC_HEADER_STDC
AC_STRUCT_TIMEZONE
AC_TYPE_SIZE_T

AC_CHECK_FUNCS(basename fchmod getcwd isascii memcpy strchr strerror uname)
AC_FUNC_ALLOCA
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_STRFTIME
AC_FUNC_VPRINTF
AC_REPLACE_FUNCS(memset mktime stpcpy strftime)
test "$ac_cv_func_basename" = yes || LIBOBJS="$LIBOBJS basename.o"

AC_MSG_CHECKING(for /etc/systemid)
if test -f /etc/systemid; then
  AC_MSG_RESULT(yes)
  AC_DEFINE(HAVE_ETC_SYSTEMID)
else
  AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(if uuencode and uudecode are wanted)
AC_ARG_ENABLE(uucode,
[  --disable-uucode        disable installation of uuencode and uudecode],
[if test "$enableval" = yes; then
  AC_MSG_RESULT(yes)
  PROGRAMS="$PROGRAMS uudecode uuencode"
  # uuencode.1 should install first, for uudecode.1 will be a link to it.
  MAN1PAGES="$MAN1PAGES uuencode uudecode"
  MAN5PAGES="$MAN5PAGES uuencode"
else
  AC_MSG_RESULT(no)
fi], [
  AC_MSG_RESULT(yes)
  PROGRAMS="$PROGRAMS uudecode uuencode"
  # uuencode.1 should install first, for uudecode.1 will be a link to it.
  MAN1PAGES="$MAN1PAGES uuencode uudecode"
  MAN5PAGES="$MAN5PAGES uuencode"
])

ud_GNU_GETTEXT
fp_WITH_DMALLOC

# sharutils is somewhat special about internationalization in that it
# always requires the GNU .mo files installed.
if test "x$CATOBJEXT" = "x.mo" || test "x$CATOBJEXT" = "x.cat"; then
  new_CATALOGS=""
  for cat in $CATALOGS; do
    lang=`echo $cat | sed "s/\(.*\)\..*/\1/"`
    new_CATALOGS="$new_CATALOGS $cat $lang.gmo"
  done
  CATALOGS="$new_CATALOGS"
fi

AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)

AC_OUTPUT([Makefile src/mail-files src/mailshar src/remsync contrib/Makefile \
	   lib/Makefile intl/Makefile intl/po2tbl.sed src/Makefile \
	   po/Makefile.in doc/Makefile checks/Makefile],
[sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile; \
 test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h])
